# {}可以进行占位
#
"""
        S.format(*args, **kwargs) -> str

        Return a formatted version of S, using substitutions from args and kwargs.
        The substitutions are identified by braces ('{' and '}').
        """
# {}
x = 'my name is {}, I am {} years old'.format('lzy', 23)
print(x)
# {index}
y = 'my name is {1}, I am {0} years old'.format(23, 'lzy')
print(y)
# {variable}
z = 'my name is {name}, I am {age} years old, I come from {addr}'.format(age=23, addr='China', name='lzy')
print(z)
# {index}和{variable}可以混合使用

# list
li = ['lzy', 23, 'China']
say = 'my name is {}, I am {} years old, I come from {}'.format(li[0], li[1], li[2])
print(say)
li = ['lzy1', 23, 'China']
say = 'my name is {}, I am {} years old, I come from {}'.format(*li)
print(say)

# dict
di = {'name': 'lzy2', 'age': 23, 'addr': 'china'}
say = 'my name is {name}, I am {age} years old, I come from {addr}, {addr}, {name}'.format(**di)
print(say)
